package com.jc.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jc.common.util.HttpUtil;
import com.jc.common.util.MD5;

public class PushOrderExpress {
	
	static String code = "jckjProduct";
	static String key = "fae05ee808e562f663fa6ce711d70dab";
	static String baseUrl = "http://jckjclub.pusai.net/thirdParty/";
	
	
	
	public static Map<String,String> emap = new HashMap<String,String>();
	public static void init() {
		
		emap.put("顺丰速运","1");
		emap.put("圆通速递","2");
		emap.put("申通快递","3");
		emap.put("韵达速递","4");
		emap.put("百世快递(原汇通)","5");
		emap.put("EMS","6");
		emap.put("中国邮政快递/包裹/挂号信/小包","7");
		emap.put("天天快递","8");
		emap.put("中通快递","9");
		emap.put("德邦物流","10");
		emap.put("京东快递","28");
		emap.put("品骏快递","29");
		emap.put("安能物流","30");
		emap.put("速尔物流","31");
		emap.put("全峰快递","32");
		emap.put("UC优速快递","33");
		emap.put("苏宁快递","34");
		emap.put("宅急送","35");
		
		
	}
	public static void main(String[] args) {
		try {
//			init();
//			getExpress();
//			pushOrder();
//			testXlsx();
//
//			pushInventory();
//			pushPic();
//
//			13
//			pushOrder(""+64176,"9","75122332568587");
			getExpress();
		}catch(Exception e) {
			e.printStackTrace();
		}
	}
	
	
	public static void pushOrder() throws Exception {
		long ts = new Date().getTime();
		Map<String,Object> body = new HashMap<String,Object>();
		body.put("code", code);
		body.put("encryptedString", MD5.passmd5("code="+code+"&ts="+String.valueOf(ts)+"&key="+key));
		body.put("ts",ts);
		
		
		body.put("channelOrderId", "31909");
		body.put("courierId", "9");
		body.put("courierNumber", "75110597197008");
		
		String ret = HttpUtil.post(baseUrl + "order/delivery", body);
		System.out.println(ret);
		
		
	}
	
	
	public static void pushOrder(String orderid,String expid,String expNo) throws Exception {
		long ts = new Date().getTime();
		Map<String,Object> body = new HashMap<String,Object>();
		body.put("code", code);
		body.put("encryptedString", MD5.passmd5("code="+code+"&ts="+String.valueOf(ts)+"&key="+key));
		body.put("ts",ts);
		
		
		body.put("channelOrderId", orderid);
		body.put("courierId", expid);
		body.put("courierNumber", expNo);
		
		String ret = HttpUtil.post(baseUrl + "order/delivery", body);
		System.out.println(ret);
		
		
	}
	//updateProduct
	
	
	public static void pushOrderPic(String details,String pics,String goodsid) throws Exception {
		
		long ts = new Date().getTime();
		Map<String,Object> body = new HashMap<String,Object>();
		body.put("code", code);
		body.put("encryptedString", MD5.passmd5("code="+code+"&ts="+String.valueOf(ts)+"&key="+key));
		body.put("ts",ts);
		
		
		body.put("productCode", goodsid);
		body.put("pics", pics);
		body.put("details", details);
		
		String ret = HttpUtil.post(baseUrl + "product/updateProductInfo", body);
		
		System.out.println(ret + "          :              " + details+"-------"+ret);
		
		
	}
	
	
	
	
	public static void pushPic() throws Exception {
		
		String driver="com.mysql.jdbc.Driver";       //1.定义驱动程序名为driver内容为com.mysql.jdbc.Driver
	     String url="jdbc:mysql://120.55.44.37:3306/oms?useUnicode=true&characterEncoding=UTF8"; //防止乱码；useUnicode=true表示使用Unicode字符集；characterEncoding=UTF8表示使用UTF-8来编辑的。
	     String user="oms";                  //3.定义用户名，写你想要连接到的用户。
	     String pass="1qaz-pl,";                 //4.用户密码。
	     Class.forName(driver);               //6.注册驱动程序，用java.lang包下面的class类里面的Class.froName();方法 此处的driver就是1里面定义的driver，也可以 Class.forName("com.mysql.jdbc.Driver");
	     Connection conn=DriverManager.getConnection(url,user,pass);//7.获取数据库连接,使用java.sql里面的DriverManager的getConnectin(String url , String username ,String password )来完成
	     
	     
	     
	     
	     
		String gids = "8190,8253,8721,8773,8779,8904,9623,9665,9755,9769,9776,9786,9786,9802,9804,9805,9806,9808,10604,10779,11354,11382,11495,11497,11498,11559,11560,11579,11603,11644,11647,11685,11783,11784,11789,11790,11791,11792,11828,11851,11998,12025,12167,12222,12253,13005,13097,13098,13099,13100,13101,13102,13103,13104,13105,13106,13107,13108,13109,13110,13111,13112,13113,13114,13115,13116,13117,13117,13117,13118,13119,13120,13121,13121,13121,13121,13122,13123,13124,13125,13127,13129,13130,13131,13137,13138,13139,13140,13141,13141,13142,13143,13143,13144,13145,13146,13147,13148,13148,13149,13150,13150,13151,13152,13152,13153,13153,13154,13154,13154,13154,13154,13154,13155,13156,13157,13157,13158,13158,13159,13159,13160,13160,13161,13161,13162,13163,13164,13165,13166,13166,13167,13167,13168,13169,13170,13171,13172,13173,13173,13173,13173,13174,13174,13175,13175,13176,13177,13178,13179,13180,13181,13182,13183,13184,13185,13185,13186,13187,13188,13189,13189,13190,13191,13192,13192,13193,13193,13194,13195,13196,13196,13197,13198,13199,13199,13199,13200,13200,13200,13201,13202,13203,13203,13204,13205,13205,13206,13207,13207,13207,13208,13209,13209,13210,13210,13210,13211,13211,13211,13212,13212,13213,13213,13213,13214,13214,13214,13214,13214,13215,13216,13216,13216,13216,13216,13216,13216,13216,13216,13216,13217,13218,13218,13218,13218,13219,13220,13220,13220,13220,13221,13221,13221,13221,13222,13222,13222,13222,13222,13223,13223,13223,13223,13223,13224,13224,13224,13224,13224,13224,13224,13224,13224,13224,13225,13225,13225,13226,13226,13226,13226,13226,13226,13226,13226,13227,13227,13227,13227,13227,13227,13227,13227,13228,13228,13228,13228,13228,13228,13228,13228,13229,13229,13229,13229,13229,13230,13230,13230,13231,13231,13231,13231,13231,13232,13232,13233,13233,13234,13234,13234,13235,13235,13235,13235,13236,13237,13238,13238,13238,13238,13238,13238,13238,13238,13239,13239,13239,13239,13239,13239,13239,13239,13239,13240,13241,13243,13244,13245,13246,13247,13248,13249,13252,13254,13255,13256,13257,13258,13259"
				+ ",13260,13261,13262,13263,13264,13265,13266,13267,13268,13269,13270,13270,13272,13272,13273,13273,13274,13274,13275,13276,13278,13279,13280,13281,13281,13281,13282,13283,13283,13283,13283,13284,13284,13284,13285,13285,13286,13286,13286,13287,13289,13289,13290,13290,13290,13291,13291,13291,13292,13293,13293,13293,13293,13294,13295,13296,13297,13298,13298,13299,13299,13300,13300,13301,13302,13303,13304,13304,13305,13306,13307,13307,13308,13309,13310,13310,13310,13310,13311,13312,13312,13312,13312,13312,13312,13313,13313,13313,13313,13313,13313,13314,13314,13314,13314,13314,13314,13314,13314,13314,13314,13314,13314,13314,13314,13315,13316,13317,13318,13319,13320,13321,13322,13323,13323,13323,13324,13325,13326,13326,13326,13327,13328,13329,13329,13329,13330,13331,13333,13334,13335,13335,13335,13335,13336,13337,13338,13339,13340,13342,13343,13344,13345,13346,13347,13348,13349,13349,13350,13350,13350,13351,13351,13353,13354,13355,13356,13357,13357,13357,13358,13359,13360,13361,13362,13363,13363,13364,13364,13365,13366,13366,13366,13367,13368,13369,13370,13371,13373,13373,13373,13373,13374,13374,13375,13376,13377,13378,13379,13380,13381,13382,13383,13384,13385,13386,13387,13388,13388,13388,13389,13390,13391,13392,13393,13394,13396,13398,13399,13400,13401,13403,13405,13406,13411,13413,13415,13416,13422,13423,13424,13426,13426,13426,13426,13429,13430";
		
		gids = "13430,13429,13426,13424,13423,13422,13416,13415,13413,13411,13406,13405,13403,13401,13400,13399,13398,13396,13394,13393,13392,13391,13390,13389,13388,13387,13386,13385,13384,13383,13382,13381,13380,13379,13378,13377,13376,13375,13374,13373,13371,13370,13369,13368,13367,13366,13365,13364,13363,13362,13361,13360,13359,13358,13357,13356,13355,13354,13353,13351,13350,13349,13348,13347,13346,13345,13344,13343,13342,13340,13339,13338,13337,13336,13335,13334,13333,13331,13330,13329,13328,13327,13326,13325,13324,13323,13322,13321,13320,13319,13318,13317,13316,13315,13314,13313,13312,13311,13310,13309,13308,13307,13306,13305,13304,13303,13302,13301,13300,13299,13298,13297,13296,13295,13294,13293,13292,13291,13290,13289,13287,13286,13285,13284,13283,13282,13281,13280,13279,13278,13276,13275,13274,13273,13272,13270,13269,13268,13267,13266,13265,13264,13263,13262,13261,13260,13259,13258,13257,13256,13255,13254,13252,13249,13248,13247,13246,13245,13244,13243,13241,13240,13239,13238,13237,13236,13235,13234,13233,13232,13231,13230,13229,13228,13227,13226,13225,13224,13223,13222,13221,13220,13219,13218,13217,13216,13215,13214,13213,13212,13211,13210,13209,13208,13207,13206,13205,13204,13203,13202,13201,13200,13199,13198,13197,13196,13195,13194,13193,13192,13191,13190,13189,13188,13187,13186,13185,13184,13183,13182,13181,13180,13179,13178,13177,13176,13175,13174,13173,13172,13171,13170,13169,13168,13167,13166,13165,13164,13163,13162,13161,13160,13159,13158,13157,13156,13155,13154,13153,13152,13151,13150,13149,13148,13147,13146,13145,13144,13143,13142,13141,13140,13139,13138,13137,13131,13130,13129,13127,13125,13124,13123,13122,13121,13120,13119,13118,13117,13116,13115,13114,13113,13112,13111,13110,13109,13108,13107,13106,13105,13104,13103,13102,13101,13100,13099,13098,13097,13005,12253,12222,12167,12025,11998,11851,11828,11792,11791,11790,11789,11784,11783,11685,11647,11644,11603,11579,11560,11559,11498,11497,11495,11382,11354,10779,10604,9808,9806,9805,9804,9802,9786,9776,9769,9755,9665,9623,8904,8779,8773,8721,8253,8190";
		//gids="8190";
		String gidss[] = gids.split(",");
		for(String gid : gidss) {
			Statement stmt=conn.createStatement();
			if(Integer.parseInt(gid) > 13357) {
				continue;
			}
			String sql = "select image_type,self_image_path from supplier_goods_picture_list where gid = "+gid+" order by image_type,image_order";
			
			String pics = "";
			String details = "";
			ResultSet rs = stmt.executeQuery(sql);
			
			while(rs.next()) {
				String type = rs.getString("image_type");
				if("1".equals(type)) {
					pics = pics + rs.getString("self_image_path") + ";";
				}else if("2".equals(type)) {//详情
					details = details + rs.getString("self_image_path") + ";";
				}
			}
			
			if(StringUtils.isNotBlank(pics)) {
				pics = pics.substring(0, (pics.length() - 1) );
			}
			
			if(StringUtils.isNotBlank(details)) {
				details = details.substring(0, (details.length() - 1) );
			}
			
			
			
			//if("13167".equals(gid)) {
//				System.out.println(gid + "---" + pics);
//				System.out.println(gid + "---" + details);
				System.out.println(gid + "---  update ...... " );
				pushOrderPic(details,pics,gid);
			//}
		}
		
		
		
	}
	
	
	public static String[] reverseArray(String[] array){
        String [] newArray = new String[array.length];
        for(int i=0; i<newArray.length; i++){
            newArray[i] = array[array.length - i - 1];
        }
        return newArray;
    }
	
	
	public static void pushInventory()throws Exception {
		
		String datas = "{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"533\",\"skuCode\":\"18409\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"575\",\"skuCode\":\"20002\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20045\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"94\",\"skuCode\":\"20380\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"10029\",\"skuCode\":\"20575\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"30258\",\"skuCode\":\"20591\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"652\",\"skuCode\":\"20624\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20865\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20866\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20867\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20869\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20872\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20874\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20876\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20877\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20878\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20879\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20880\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20881\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20883\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20884\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"20888\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"30059\",\"skuCode\":\"21328\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"153\",\"skuCode\":\"21329\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"27\",\"skuCode\":\"21616\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"179\",\"skuCode\":\"21738\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"4986\",\"skuCode\":\"21874\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"1\",\"skuCode\":\"21964\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"22347\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"996\",\"skuCode\":\"22421\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"23450\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"986\",\"skuCode\":\"23557\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"32507\",\"skuCode\":\"23573\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"95\",\"skuCode\":\"23581\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"420\",\"skuCode\":\"23615\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"159\",\"skuCode\":\"23617\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"4690\",\"skuCode\":\"24169\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"24554\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"999\",\"skuCode\":\"24700\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24958\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24959\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24960\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24961\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24963\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24965\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"24968\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"872\",\"skuCode\":\"25572\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"2999\",\"skuCode\":\"25733\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"8\",\"skuCode\":\"25771\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"109\",\"skuCode\":\"25794\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"19\",\"skuCode\":\"25906\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"473\",\"skuCode\":\"26258\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"26383\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"26384\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"98\",\"skuCode\":\"26887\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"498\",\"skuCode\":\"27447\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"22\",\"skuCode\":\"27466\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"74\",\"skuCode\":\"28055\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"497\",\"skuCode\":\"28852\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"28981\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"28982\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"28984\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"29219\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"1160\",\"skuCode\":\"30058\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"854\",\"skuCode\":\"30063\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"9831\",\"skuCode\":\"30065\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"9864\",\"skuCode\":\"30071\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"9834\",\"skuCode\":\"30075\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"80\",\"skuCode\":\"30612\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"98\",\"skuCode\":\"31536\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"323\",\"skuCode\":\"31606\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"31730\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"20\",\"skuCode\":\"31777\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"997\",\"skuCode\":\"34011\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"999\",\"skuCode\":\"34010\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34015\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34027\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"2\",\"skuCode\":\"34064\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"499\",\"skuCode\":\"34104\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34139\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34105\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34124\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34156\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34135\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34136\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34084\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34097\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34122\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34085\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34086\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34087\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34088\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34089\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34090\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34080\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"34201\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"100\",\"skuCode\":\"34202\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"499\",\"skuCode\":\"34209\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34210\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34211\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34212\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34213\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34214\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34215\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"989\",\"skuCode\":\"34219\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"999\",\"skuCode\":\"34218\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"999\",\"skuCode\":\"34217\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"0\",\"skuCode\":\"34270\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"497\",\"skuCode\":\"34306\",\"ts\":1548237975377}|{\"code\":\"jckjProduct\",\"encryptedString\":\"062af3b756557964c1ac6ba0f9aa7a04\",\"inventory\":\"98\",\"skuCode\":\"34388\",\"ts\":1548237975377}";
		
		String[] js = datas.split("\\|");
		
		
		js = reverseArray(js);
		//product/updateProduct
		String url = "http://jckjclub.pusai.net/thirdParty/product/updateProduct";
		for(String s : js) {
			
			Map<String ,Object> o;
			
			Map<String,Object> map = JSONObject.parseObject(s, Map.class);
			
			if(StringUtils.isNotBlank(map.get("inventory").toString())) {
				//map
				
				System.out.println(map.get("inventory").toString());
				if(Integer.parseInt(map.get("inventory").toString()) > 0) {
					map.put("inventory", "0");
					
					//System.out.println(JSONObject.toJSONString(map));
					
					/*String ret = HttpUtil.post(url, map);
					System.out.println(map.get("skuCode") + "  ----   " + ret);
					Thread.sleep(200);*/
				}
				
				
				
			}
			
			
		
			
			
			//Thread.sleep(300);
			
			
			
			
		}
		
		
		
	}
	
	public static void getExpress()throws Exception {
		long ts = new Date().getTime();
		Map<String,Object> body = new HashMap<String,Object>();
		body.put("code", code);
		body.put("encryptedString", MD5.passmd5("code="+code+"&ts="+String.valueOf(ts)+"&key="+key));
		body.put("ts",ts);
		
		String url = baseUrl + "order/logisticsCompany";
		System.out.println(url);
		//String ret = HttpUtil.postJson( url, JSONObject.toJSONString(body), null);
		String ret = HttpUtil.get( url, body);
		System.out.println(ret);
		
		
		if(StringUtils.isNotBlank(ret)) {
			JSONObject expobj = JSONObject.parseObject(ret);
			JSONArray arr = expobj.getJSONArray("list");
			for(int i = 0 ; arr != null && i < arr.size() ; i++) {
				JSONObject exp = arr.getJSONObject(i);
				String name = exp.getString("name");
				String id = exp.getString("id");
				String code = exp.getString("code");
				//System.out.println("emap.put(\""+name+"\",\""+id+"\");");
				//INSERT INTO `oms`.`logistics_company`(`id`, `channel_logistics_id`, `channel_id`, `name`, `code`, `extend1`, `extend2`, `extend3`, `extend4`, `extend5`) VALUES (1, '332', '3000', '顺丰', 'sf', NULL, NULL, NULL, NULL, NULL);

				//System.out.println(JSONObject.toJSONString(exp));
				//System.out.println(" INSERT INTO `oms`.`logistics_company`( `channel_logistics_id`, `channel_id`, `name`, `code`, `extend1`, `extend2`, `extend3`, `extend4`, `extend5`) VALUES ('"+id+"', '3000', '"+name+"', '"+code+"', NULL, NULL, NULL, NULL, NULL); ");
				
				
				
			}
		}
	}
	
	
	
	public static void testXlsx() throws Exception {
	    File file = new File("H:\\0122\\2222.xlsx");
	    System.out.println(file.exists());
	    //获取输入流  
	    InputStream stream = new FileInputStream(file); 
	    Workbook xssfWorkbook = new XSSFWorkbook(stream); 
	    Sheet sheet = xssfWorkbook.getSheetAt(2); 
	    
	    //获得当前sheet的开始行
        int firstRowNum  = sheet.getFirstRowNum();
        //获得当前sheet的结束行
        int lastRowNum = sheet.getLastRowNum();
        //循环除了第一行的所有行
        int count = 0;
        for(int rowNum = firstRowNum+0;rowNum <= lastRowNum;rowNum++){ //为了过滤到第一行因为我的第一行是数据库的列
        	//获得当前行
        	Row row = sheet.getRow(rowNum);
        	//Cell cell1 = row.getCell(0);
        	Cell cell2 = row.getCell(1);
        	Cell cell3 = row.getCell(2);
        	Cell cell4 = row.getCell(3);
        	//System.out.println("cell2" + cell2.getStringCellValue());
        	String orderid = null;
        	if(cell2 != null) {
        		//orderid = String.valueOf(new Double(cell2.getNumericCellValue()).intValue());
        		orderid = cell2.getStringCellValue();
        		if(StringUtils.isNotBlank(orderid)) {
//        			orderid = orderid.trim();
        			orderid = StringUtils.trim(orderid);
        		}
        	}
        	
        	//System.out.println("cell3");
        	String expname = null;
        	if(cell3 != null) {
        		expname = cell3.getStringCellValue();
        	}
        	
        	//System.out.println("cell4");
        	String expNo = null;
        	if(cell4 != null) {
        		expNo = String.valueOf(cell4.getStringCellValue());
        	}

        	if(StringUtils.isNotBlank(orderid) && StringUtils.isNotBlank(expname) && StringUtils.isNotBlank(expNo)) {
        		count++;
        		
//        		if( count <+ 220 ) {
//        			continue;
//        		}
        		String expid = emap.get(expname);
        		
        		
        		if(orderid.indexOf("-") > 0) {
        			orderid = orderid.split("-")[1];
        			
        		}
        		if(StringUtils.isNotBlank(orderid)) {
        			orderid = orderid.trim();
        		}
        		System.out.println(count + " " + orderid + "----------------" + expname + "----------- " + expNo + "-----  "  + expid);
        		if(expid != null) {
        			pushOrder(orderid,expid,expNo);
        		}
        		//pushOrder(orderid,expid,expNo);
        	}
        }
	}
	
	
	

}
